﻿#include "uploadfile.h"

QString afiletype="7500";
QString afilepath;
QStringList STRTypeopath;
QStringList STRNameopath;
QStringList STRsysopath;
extern QStringList STRType;
extern QStringList STRName;
extern QStringList STRsys;
/**
     * @brief 构造函数
*/
UploadFile::UploadFile()
{

}

/**
   * @brief 析构函数
*/
UploadFile::~UploadFile()
{

}
// 定量仪器文件选择
// 前端仪器读
Q_INVOKABLE QStringList UploadFile::kzyqname(){
    QString sql="SELECT Name FROM ItemCode WHERE DicCode=13 ";
    QSqlDatabase db = dbHelper::openConnection();
    QSqlQuery query(db);
    QStringList sanames;
    query.exec(sql);
    while (query.next()) {
        QString column1Value = query.value("Name").toString();
        sanames.append(column1Value);
    }
    query.clear();
    return sanames;
}
// 前端仪器写
Q_INVOKABLE void UploadFile::fileTypeChange(QString type){
    afiletype = type;
}
// 选择文件
Q_INVOKABLE QString UploadFile::fileChoose(){
    afilepath = QFileDialog::getOpenFileName(nullptr, tr("Open Excel file"), "", tr("Excel Files (*.xlsx *.xls)"));  // 获取 Excel 文件路径

    QXlsx::Document xlsx(afilepath);
    QStringList sheetnames =xlsx.sheetNames();
    if (!afilepath.isEmpty()){
        if(afiletype=="7500"){
            if(sheetnames.contains("Results")){
                xlsx.selectSheet("Results");
                QStringList title;
                for(int i=1;i<9;i++){
                    title.append(xlsx.read(8,i).toString());
                }
                qDebug()<<title;
                if(title[0]=="Well"&&title[1]=="Sample Name"&&title[2]=="Target Name"&&title[3]=="Task"&&title[4]=="Reporter"&&title[5]=="Quencher"&&title[6]=="Cт"&&title[7]=="Cт Mean"){
                    filefl=true;
                }else{
                    QMessageBox::warning(nullptr,"提示","数据文件格式不正确！");
                    return NULL;
                }
            }else{
                QMessageBox::warning(nullptr,"提示","请选择7500实验结果文件！");
                return NULL;
            }
        }else if(afiletype=="7500线上"){
            if(sheetnames.contains("Standard Curve Result")){
                xlsx.selectSheet("Standard Curve Result");
                if(xlsx.read(26,2).toString()=="Well Position"&&xlsx.read(26,3).toString()=="Sample"&&xlsx.read(26,5).toString()=="Target"&&xlsx.read(26,6).toString()=="Dye"
                        &&xlsx.read(26,7).toString()=="Task"&&xlsx.read(26,11).toString()=="Cq"&&xlsx.read(26,12).toString()=="Cq Mean"&&xlsx.read(26,4).toString()=="Quantity"){
                    filefl=true;
                }else{
                    QMessageBox::warning(nullptr,"提示","数据文件格式不正确！");
                    return NULL;
                }
            }else{
                QMessageBox::warning(nullptr,"提示","请选择7500线上实验结果文件！");
                return NULL;
            }
        }else if(afiletype=="鲲鹏"){
            if(sheetnames.contains("结果")){
                xlsx.selectSheet("结果");
                int colu=1;
                for(int i=1;i<xlsx.dimension().rowCount();i++){
                    QString celll = xlsx.read(i,2).toString();
                    if(celll=="孔"){
                        colu = i;
                        break;
                    }
                }
                if(xlsx.read(colu,2).toString()=="孔"&&xlsx.read(colu,3).toString()=="样本名称"&&xlsx.read(colu,4).toString()=="检测项目"&&xlsx.read(colu,6).toString()=="荧光染料"
                        &&xlsx.read(colu,5).toString()=="检测类型"&&xlsx.read(colu,7).toString()=="Cq"&&xlsx.read(colu,8).toString()=="Cq平均值"&&xlsx.read(colu,14).toString()=="浓度"){
                    filefl=true;
                }else{
                    QMessageBox::warning(nullptr,"提示","数据文件格式不正确！");
                    return NULL;
                }
            }else{
                QMessageBox::warning(nullptr,"提示","请选择鲲鹏实验结果文件！");
                return NULL;
            }
        }else if(afiletype=="Q5"){
            if(sheetnames.contains("结果分析")){
                xlsx.selectSheet("结果分析");
                if(xlsx.read(47,2).toString()=="反应孔位置"&&xlsx.read(47,4).toString()=="样本名"&&xlsx.read(47,5).toString()=="基因名称"&&xlsx.read(47,7).toString()=="报告基团"
                        &&xlsx.read(47,6).toString()=="任务"&&xlsx.read(47,9).toString()=="CRT"&&xlsx.read(47,10).toString()=="Crt 平均值"&&xlsx.read(47,12).toString()=="Quantity"){
                    filefl=true;
                }else{
                    QMessageBox::warning(nullptr,"提示","数据文件格式不正确！");
                    return NULL;
                }
            }else{
                QMessageBox::warning(nullptr,"提示","请选择Q5实验结果文件！");
                return NULL;
            }
        }else if(afiletype=="Q5英文版"){
            if(sheetnames.contains("Results")){
                xlsx.selectSheet("Results");
                if(xlsx.read(47,2).toString()=="Well Position"&&xlsx.read(47,4).toString()=="Sample Name"&&xlsx.read(47,5).toString()=="Target Name"&&xlsx.read(47,7).toString()=="Reporter"
                        &&xlsx.read(47,6).toString()=="Task"&&xlsx.read(47,9).toString()=="CRT"&&xlsx.read(47,10).toString()=="Crt Mean"&&xlsx.read(47,12).toString()=="Quantity"){
                    filefl=true;
                }else{
                    QMessageBox::warning(nullptr,"提示","数据文件格式不正确！");
                    return NULL;
                }
            }else{
                QMessageBox::warning(nullptr,"提示","请选择Q5英文版实验结果文件！");
                return NULL;
            }
        }else if(afiletype=="伯乐"){
            if(sheetnames.contains("0")){
                xlsx.selectSheet("0");
                if(xlsx.read(1,2).toString()=="Well"&&xlsx.read(1,3).toString()=="Fluor"&&xlsx.read(1,4).toString()=="Target"&&xlsx.read(1,5).toString()=="Content"&&
                        xlsx.read(1,6).toString()=="Sample"&&xlsx.read(1,8).toString()=="Cq"&&xlsx.read(1,9).toString()=="Cq Mean"&&xlsx.read(1,11).toString()=="Starting Quantity (SQ)"){
                    filefl=true;
                }else{
                    QMessageBox::warning(nullptr,"提示","数据文件格式不正确！");
                    return NULL;
                }
            }else{
                QMessageBox::warning(nullptr,"提示","请选择伯乐实验结果文件！");
                return NULL;
            }
        }else if(afiletype=="Design and Analysis-线下版"){
            if(sheetnames.contains("Standard Curve Result")){
                xlsx.selectSheet("Standard Curve Result");
                if(xlsx.read(25,2).toString()=="Well Position"&&xlsx.read(25,3).toString()=="Sample"&&xlsx.read(25,5).toString()=="Target"&&xlsx.read(25,8).toString()=="Reporter"
                        &&xlsx.read(25,7).toString()=="Task"&&xlsx.read(25,11).toString()=="Cq"&&xlsx.read(25,12).toString()=="Cq Mean"&&xlsx.read(25,4).toString()=="Quantity"){
                    filefl=true;
                }else{
                    QMessageBox::warning(nullptr,"提示","数据文件格式不正确！");
                    return NULL;
                }
            }else{
                QMessageBox::warning(nullptr,"提示","请选择Design and Analysis-线下版实验结果文件！");
                return NULL;
            }
        }
    }else{
        QMessageBox::warning(nullptr,"提示","您选择的文件为空，请重新选择!");
        return NULL;
    }
    return afilepath;
}
// 定量仪器文件选择
// 前端仪器读
Q_INVOKABLE QStringList UploadFile::jyfxyname(){
    QString sql="SELECT Name FROM ItemCode WHERE DicCode=14 ";
    QSqlDatabase db = dbHelper::openConnection();
    QSqlQuery query(db);
    QStringList sanames;
    query.exec(sql);
    while (query.next()) {
        QString column1Value = query.value("Name").toString();
        sanames.append(column1Value);
    }
    query.clear();
    return sanames;
}
// 类型选中
Q_INVOKABLE void UploadFile::isched(int index,QString flag){
    ische[index] = flag;
    qDebug()<<ische;
}
// 名字选中
Q_INVOKABLE void UploadFile::isname(int index,QString name){
    names[index] = name;
    qDebug()<<names;
}
// 体系
Q_INVOKABLE void UploadFile::isvolume(int index, QString volume)
{
    volumes[index] = volume;
    qDebug()<<volumes;
}
// 前端名字查询
Q_INVOKABLE QVariantList UploadFile::allnames(){
    QSqlDatabase db = dbHelper::openConnection();
    QSqlQuery query(db);
    QString sql=QString("SELECT Name FROM ItemCode WHERE DicCode='%1'").arg(16);
    QStringList nameval1,nameval2,nameval3;
    query.exec(sql);
    while (query.next()) {
        QString column2Value = query.value("Name").toString();
        nameval1.append(column2Value);
    }
    sql=QString("SELECT Name FROM ItemCode WHERE DicCode='%1'").arg(17);
    query.exec(sql);
    while (query.next()) {
        QString column2Value = query.value("Name").toString();
        nameval2.append(column2Value);
    }
    sql=QString("SELECT Name FROM ItemCode WHERE DicCode='%1'").arg(18);
    query.exec(sql);
    while (query.next()) {
        QString column2Value = query.value("Name").toString();
        nameval3.append(column2Value);
    }
    QVariantList allval;
    allval<<nameval1<<nameval2<<nameval3;
    return allval;
}
// 体系查询
Q_INVOKABLE QVariantList UploadFile::allvolumes()
{
    QSqlDatabase db = dbHelper::openConnection();
    QSqlQuery query(db);
    QString sql=QString("SELECT Name FROM ItemCode WHERE DicCode='%1'").arg(19);
    QStringList nameval1;
    query.exec(sql);
    while (query.next()) {
        QString column2Value = query.value("Name").toString();
        nameval1.append(column2Value);
    }
    QVariantList allval;
    allval<<nameval1<<nameval1<<nameval1;
    return allval;
}
// 校验
Q_INVOKABLE int UploadFile::jy(){
    if(afilepath==""){
        QMessageBox::warning(nullptr,"提示","请先上传定量仪器文件！");
        return 1;
    }
    if(filefl){
        if(ische[0]=="0"&&ische[1]=="0"&&ische[2]=="0"){
            QMessageBox::warning(nullptr,"提示","请选择分析模型！");
            return 1;
        }
        for(int i=0;i<ische.length();i++){
            if(ische[i]=="1"){
                QSqlDatabase db = dbHelper::openConnection();
                qDebug()<<types[i]<<names[i]<<volumes[i];
                QString sql=QString("SELECT ReagentKitType,ReagentKitName,System FROM DataAnalyseConfig WHERE ReagentKitType='%1' and ReagentKitName='%2' and System='%3' ")
                        .arg(types[i],names[i],volumes[i]);
                qDebug()<<sql;
                QStringList namesfl;
                QSqlQuery query(db);
                query.exec(sql);
                while (query.next()) {
                    QString namesf = query.value("ReagentKitType").toString();
                    namesfl.append(namesf);
                }

                if(namesfl.length()==0){
                    QMessageBox::warning(nullptr,"提示","未找到匹配的模型！");
                    return 1;
                }
            }
            return 0;
        }
    }else{
        QMessageBox::warning(nullptr,"提示","请确认文件路径是否正确！");
        return 1;
    }
}
// 数据导入计算
Q_INVOKABLE void UploadFile::datain()
{
    QXlsx::Document xlsx(afilepath);
    QStringList sheetnames =xlsx.sheetNames();
    if (!afilepath.isEmpty()){
        if(afiletype=="7500"){
            xlsx.selectSheet("Results");
            AL=" AL: R²:""暂无"" Y轴截距:""暂无"" 扩增效率:""暂无"" 斜率:""暂无";
            AS=" AS: R²:""暂无"" Y轴截距:""暂无"" 扩增效率:""暂无"" 斜率:""暂无";
            Y=" Y: R²:""暂无"" Y轴截距:""暂无"" 扩增效率:""暂无"" 斜率:""暂无";
            QVector<QStringList> dataList;
            QStringList rowdata;
            for(int i=9;i<xlsx.dimension().rowCount()+1;i++){
                rowdata.clear();
                if(xlsx.read(i,2).toString()!=""){
                    rowdata<<xlsx.read(i,1).toString()<<xlsx.read(i,2).toString()<<xlsx.read(i,4).toString()
                          <<xlsx.read(i,5).toString()<<QString::number(xlsx.read(i,7).toDouble(),'f',2)
                         <<QString::number(xlsx.read(i,10).toDouble(),'f',2);
                    dataList.append(rowdata);
                }
            }
            table1Data=dataList;
            table();
        }else if(afiletype=="7500线上"){
            xlsx.selectSheet("Standard Curve Result");
            double RRR = xlsx.read(27,27).toDouble();
            QString R1 = QString::number(RRR,'f',2);
            double RRV = xlsx.read(28,27).toDouble();
            QString V1 = QString::number(RRV,'f',2);
            double RRF = xlsx.read(29,27).toDouble();
            QString F1 = QString::number(RRF,'f',2);
            double JJR = xlsx.read(27,26).toDouble();
            QString R2 = QString::number(JJR,'f',2);
            double JJV = xlsx.read(28,27).toDouble();
            QString V2 = QString::number(JJV,'f',2);
            double JJF = xlsx.read(29,27).toDouble();
            QString F2 = QString::number(JJF,'f',2);
            double XLR = xlsx.read(27,29).toDouble();
            QString R3 = QString::number(XLR,'f',2);
            double XLV = xlsx.read(28,29).toDouble();
            QString V3 = QString::number(XLV,'f',2);
            double XLF = xlsx.read(29,29).toDouble();
            QString F3 = QString::number(XLF,'f',2);
            double XR = xlsx.read(27,28).toDouble();
            QString R4 = QString::number(XR,'f',2);
            double XV = xlsx.read(28,28).toDouble();
            QString V4 = QString::number(XV,'f',2);
            double XF = xlsx.read(29,27).toDouble();
            QString F4 = QString::number(XF,'f',2);
            AL=" AL: R²:"+R1+" Y轴截距:"+R2+" 扩增效率:"+R3+" 斜率:"+R4+"\n";
            AS=" AS: R²:"+V1+" Y轴截距:"+V2+" 扩增效率:"+V3+" 斜率:"+V4+"\n";
            Y=" Y: R²:"+F1+" Y轴截距:"+F2+" 扩增效率:"+F3+" 斜率:"+F4+"\n";
            QVector<QStringList> dataList;
            QStringList rowdata;
            for(int i=27;i<xlsx.dimension().rowCount()+1;i++){
                rowdata.clear();
                rowdata<<xlsx.read(i,2).toString()<<xlsx.read(i,3).toString()<<xlsx.read(i,7).toString()
                      <<xlsx.read(i,8).toString()<<QString::number(xlsx.read(i,11).toDouble(),'f',2)
                     <<QString::number(xlsx.read(i,4).toDouble(),'f',2);
                dataList.append(rowdata);
            }
            table1Data=dataList;
            table();
        }else if(afiletype=="鲲鹏"){
            xlsx.selectSheet("结果");
            int colu=1;
            for(int i=1;i<xlsx.dimension().rowCount();i++){
                QString celll = xlsx.read(i,2).toString();
                if(celll=="孔"){
                    colu = i;
                    break;
                }
            }
            double RRR = xlsx.read(colu+1,10).toDouble();
            QString R1 = QString::number(RRR,'f',2);
            double RRV = xlsx.read(colu+2,10).toDouble();
            QString V1 = QString::number(RRV,'f',2);
            double RRF = xlsx.read(colu+3,10).toDouble();
            QString F1 = QString::number(RRF,'f',2);
            double JJR = xlsx.read(colu+1,11).toDouble();
            QString R2 = QString::number(JJR,'f',2);
            double JJV = xlsx.read(colu+2,11).toDouble();
            QString V2 = QString::number(JJV,'f',2);
            double JJF = xlsx.read(colu+3,11).toDouble();
            QString F2 = QString::number(JJF,'f',2);
            double XLR = xlsx.read(colu+1,12).toDouble();
            QString R3 = QString::number(XLR,'f',2);
            double XLV = xlsx.read(colu+1,12).toDouble();
            QString V3 = QString::number(XLV,'f',2);
            double XLF = xlsx.read(colu+1,12).toDouble();
            QString F3 = QString::number(XLF,'f',2);
            double XR = xlsx.read(colu+1,13).toDouble();
            QString R4 = QString::number(XR,'f',2);
            double XV = xlsx.read(colu+1,13).toDouble();
            QString V4 = QString::number(XV,'f',2);
            double XF = xlsx.read(colu+1,13).toDouble();
            QString F4 = QString::number(XF,'f',2);
            AL=" AL: R²:"+R1+" Y轴截距:"+R2+" 扩增效率:"+R3+" 斜率:"+R4+"\n";
            AS=" AS: R²:"+V1+" Y轴截距:"+V2+" 扩增效率:"+V3+" 斜率:"+V4+"\n";
            Y=" Y: R²:"+F1+" Y轴截距:"+F2+" 扩增效率:"+F3+" 斜率:"+F4+"\n";
            QVector<QStringList> dataList;
            QStringList rowdata;
            for(int i=colu+1;i<xlsx.dimension().rowCount()+1;i++){
                rowdata.clear();
                rowdata<<xlsx.read(i,2).toString()<<xlsx.read(i,3).toString()<<xlsx.read(i,5).toString()
                      <<xlsx.read(i,6).toString()<<QString::number(xlsx.read(i,7).toDouble(),'f',2)
                     <<QString::number(xlsx.read(i,14).toDouble(),'f',2);
                dataList.append(rowdata);
            }
            table1Data=dataList;
            table();
        }else if(afiletype=="Q5"){
            xlsx.selectSheet("结果分析");
            for(int i=48;i<xlsx.dimension().rowCount();i++){
                QString cell_valueBZE = xlsx.read(i,6).toString();
                if(cell_valueBZE=="STANDARD"){
                    for(int j=i;j<i+4;j++){
                        QString cell_valueYE = xlsx.read(j,7).toString();
                        bzend.append(cell_valueYE);
                    }
                    break;
                }
            }
            for(int i=48;i<xlsx.dimension().rowCount();i++){
                QString cell_valueBZE = xlsx.read(i,6).toString();
                if(cell_valueBZE=="UNKNOWN"){
                    for(int j=i;j<i+4;j++){
                        QString cell_valueYE = xlsx.read(j,7).toString();
                        fbzend.append(cell_valueYE);
                    }
                    break;
                }
            }
            vaend.append("ROX");
            vaend.append("VIC");
            vaend.append("FAM");
            vaend.append("CY5");
            for (int i = 0; i < 4; ++i) {
                for(int j = 0; j < 4; j++){
                    if ( vaend[i]==bzend.at(j) ) {
                        bzed.append(j);
                    }
                }
            }
            for (int i = 0; i < 4; ++i) {
                for(int j = 0; j < 4; j++){
                    if ( vaend[i]== fbzend.at(j)) {
                        fbzed.append(j);
                    }
                }
            }
            double RRR = xlsx.read(48+bzed[0], 16).toDouble();
            QString R1 = QString::number(RRR,'f',4);
            double RRV = xlsx.read(48+bzed[1], 16).toDouble();
            QString V1 = QString::number(RRV,'f',4);
            double RRF = xlsx.read(48+bzed[2], 16).toDouble();
            QString F1 = QString::number(RRF,'f',4);
            double JJR = xlsx.read(48+bzed[0], 15).toDouble();
            QString R2 = QString::number(JJR,'f',4);
            double JJV = xlsx.read(48+bzed[1], 15).toDouble();
            QString V2 = QString::number(JJV,'f',4);
            double JJF = xlsx.read(48+bzed[2], 15).toDouble();
            QString F2 = QString::number(JJF,'f',4);
            double XLR = xlsx.read(48+bzed[0], 18).toDouble();
            QString R3 = QString::number(XLR,'f',4);
            double XLV = xlsx.read(48+bzed[1], 18).toDouble();
            QString V3 = QString::number(XLV,'f',4);
            double XLF = xlsx.read(48+bzed[2], 18).toDouble();
            QString F3 = QString::number(XLF,'f',4);
            double XR = xlsx.read(48+bzed[0], 17).toDouble();
            QString R4 = QString::number(XR,'f',4);
            double XV = xlsx.read(48+bzed[1], 17).toDouble();
            QString V4 = QString::number(XV,'f',4);
            double XF = xlsx.read(48+bzed[2], 17).toDouble();
            QString F4 = QString::number(XF,'f',4);
            AL=" AL: R²:"+R1+" Y轴截距:"+R2+" 扩增效率:"+R3+" 斜率:"+R4+"\n";
            AS=" AS: R²:"+V1+" Y轴截距:"+V2+" 扩增效率:"+V3+" 斜率:"+V4+"\n";
            Y=" Y: R²:"+F1+" Y轴截距:"+F2+" 扩增效率:"+F3+" 斜率:"+F4+"\n";
            QVector<QStringList> dataList;
            QStringList rowdata;
            for(int i=48;i<xlsx.dimension().rowCount()+1;i++){
                rowdata.clear();
                rowdata<<xlsx.read(i,2).toString()<<xlsx.read(i,4).toString()<<xlsx.read(i,6).toString()
                      <<xlsx.read(i,7).toString()<<QString::number(xlsx.read(i,9).toDouble(),'f',2)
                     <<QString::number(xlsx.read(i,12).toDouble(),'f',2);
                dataList.append(rowdata);
            }
            table1Data=dataList;
            table();
        }else if(afiletype=="Q5英文版"){
            xlsx.selectSheet("Results");
            for(int i=48;i<xlsx.dimension().rowCount();i++){
                QString cell_valueBZE = xlsx.read(i,6).toString();
                if(cell_valueBZE=="STANDARD"){
                    for(int j=i;j<i+4;j++){
                        QString cell_valueYE = xlsx.read(j,7).toString();
                        bzend.append(cell_valueYE);
                    }
                    break;
                }
            }
            for(int i=48;i<xlsx.dimension().rowCount();i++){
                QString cell_valueBZE = xlsx.read(i,6).toString();
                if(cell_valueBZE=="UNKNOWN"){
                    for(int j=i;j<i+4;j++){
                        QString cell_valueYE = xlsx.read(j,7).toString();
                        fbzend.append(cell_valueYE);
                    }
                    break;
                }
            }
            vaend.append("ROX");
            vaend.append("VIC");
            vaend.append("FAM");
            vaend.append("CY5");
            for (int i = 0; i < 4; ++i) {
                for(int j = 0; j < 4; j++){
                    if ( vaend[i]==bzend.at(j) ) {
                        bzed.append(j);
                    }
                }
            }
            for (int i = 0; i < 4; ++i) {
                for(int j = 0; j < 4; j++){
                    if ( vaend[i]== fbzend.at(j)) {
                        fbzed.append(j);
                    }
                }
            }
            double RRR = xlsx.read(48+bzed[0], 16).toDouble();
            QString R1 = QString::number(RRR,'f',4);
            double RRV = xlsx.read(48+bzed[1], 16).toDouble();
            QString V1 = QString::number(RRV,'f',4);
            double RRF = xlsx.read(48+bzed[2], 16).toDouble();
            QString F1 = QString::number(RRF,'f',4);
            double JJR = xlsx.read(48+bzed[0], 15).toDouble();
            QString R2 = QString::number(JJR,'f',4);
            double JJV = xlsx.read(48+bzed[1], 15).toDouble();
            QString V2 = QString::number(JJV,'f',4);
            double JJF = xlsx.read(48+bzed[2], 15).toDouble();
            QString F2 = QString::number(JJF,'f',4);
            double XLR = xlsx.read(48+bzed[0], 18).toDouble();
            QString R3 = QString::number(XLR,'f',4);
            double XLV = xlsx.read(48+bzed[1], 18).toDouble();
            QString V3 = QString::number(XLV,'f',4);
            double XLF = xlsx.read(48+bzed[2], 18).toDouble();
            QString F3 = QString::number(XLF,'f',4);
            double XR = xlsx.read(48+bzed[0], 17).toDouble();
            QString R4 = QString::number(XR,'f',4);
            double XV = xlsx.read(48+bzed[1], 17).toDouble();
            QString V4 = QString::number(XV,'f',4);
            double XF = xlsx.read(48+bzed[2], 17).toDouble();
            QString F4 = QString::number(XF,'f',4);
            AL=" AL: R²:"+R1+" Y轴截距:"+R2+" 扩增效率:"+R3+" 斜率:"+R4+"\n";
            AS=" AS: R²:"+V1+" Y轴截距:"+V2+" 扩增效率:"+V3+" 斜率:"+V4+"\n";
            Y=" Y: R²:"+F1+" Y轴截距:"+F2+" 扩增效率:"+F3+" 斜率:"+F4+"\n";
            QVector<QStringList> dataList;
            QStringList rowdata;
            for(int i=48;i<xlsx.dimension().rowCount()+1;i++){
                rowdata.clear();
                rowdata<<xlsx.read(i,2).toString()<<xlsx.read(i,4).toString()<<xlsx.read(i,6).toString()
                      <<xlsx.read(i,7).toString()<<QString::number(xlsx.read(i,9).toDouble(),'f',2)
                     <<QString::number(xlsx.read(i,12).toDouble(),'f',2);
                dataList.append(rowdata);
            }
            table1Data=dataList;
            table();
        }else if(afiletype=="伯乐"){
            xlsx.selectSheet("0");
            QVector<QStringList> dataList;
            QStringList rowdata;
            for(int i=2;i<xlsx.dimension().rowCount()+1;i++){
                rowdata.clear();
                rowdata<<xlsx.read(i,2).toString()<<xlsx.read(i,6).toString()<<xlsx.read(i,5).toString()
                      <<xlsx.read(i,3).toString()<<QString::number(xlsx.read(i,8).toDouble(),'f',2)
                     <<QString::number(xlsx.read(i,11).toDouble(),'f',2);
                dataList.append(rowdata);
            }
            table1Data=dataList;
            table();

        }else if(afiletype=="Design and Analysis-线下版"){
            xlsx.selectSheet("Standard Curve Result");
            for(int i=26;i<xlsx.dimension().rowCount();i++){
                QString cell_valueBZE = xlsx.read(i,7).toString();
                if(cell_valueBZE=="STANDARD"){
                    for(int j=i;j<i+4;j++){
                        QString cell_valueYE = xlsx.read(j,8).toString();
                        bzend.append(cell_valueYE);
                    }
                    break;
                }
            }
            for(int i=26;i<xlsx.dimension().rowCount();i++){
                QString cell_valueBZE = xlsx.read(i,7).toString();
                if(cell_valueBZE=="UNKNOWN"){
                    for(int j=i;j<i+4;j++){
                        QString cell_valueYE = xlsx.read(j,8).toString();
                        fbzend.append(cell_valueYE);
                    }
                    break;
                }
            }
            vaend.append("ROX");
            vaend.append("VIC");
            vaend.append("FAM");
            vaend.append("CY5");
            for (int i = 0; i < 4; ++i) {
                for(int j = 0; j < 4; j++){
                    if ( vaend[i]==bzend.at(j) ) {
                        bzed.append(j);
                    }
                }
            }
            for (int i = 0; i < 4; ++i) {
                for(int j = 0; j < 4; j++){
                    if ( vaend[i]== fbzend.at(j)) {
                        fbzed.append(j);
                    }
                }
            }
            qDebug()<<bzend<<fbzend;
            qDebug()<<bzed<<fbzed;
            double RRR = xlsx.read(26+bzed[0], 27).toDouble();
            QString R1 = QString::number(RRR,'f',4);
            double RRV = xlsx.read(26+bzed[1], 27).toDouble();
            QString V1 = QString::number(RRV,'f',4);
            double RRF = xlsx.read(26+bzed[2], 27).toDouble();
            QString F1 = QString::number(RRF,'f',4);
            double JJR = xlsx.read(26+bzed[0], 26).toDouble();
            QString R2 = QString::number(JJR,'f',4);
            double JJV = xlsx.read(26+bzed[1], 26).toDouble();
            QString V2 = QString::number(JJV,'f',4);
            double JJF = xlsx.read(26+bzed[2], 26).toDouble();
            QString F2 = QString::number(JJF,'f',4);
            double XLR = xlsx.read(26+bzed[0], 29).toDouble();
            QString R3 = QString::number(XLR,'f',4);
            double XLV = xlsx.read(26+bzed[1], 29).toDouble();
            QString V3 = QString::number(XLV,'f',4);
            double XLF = xlsx.read(26+bzed[2], 29).toDouble();
            QString F3 = QString::number(XLF,'f',4);
            double XR = xlsx.read(26+bzed[0], 28).toDouble();
            QString R4 = QString::number(XR,'f',4);
            double XV = xlsx.read(26+bzed[1], 28).toDouble();
            QString V4 = QString::number(XV,'f',4);
            double XF = xlsx.read(26+bzed[2], 28).toDouble();
            QString F4 = QString::number(XF,'f',4);
            AL=" AL: R²:"+R1+" Y轴截距:"+R2+" 扩增效率:"+R3+" 斜率:"+R4+"\n";
            AS=" AS: R²:"+V1+" Y轴截距:"+V2+" 扩增效率:"+V3+" 斜率:"+V4+"\n";
            Y=" Y: R²:"+F1+" Y轴截距:"+F2+" 扩增效率:"+F3+" 斜率:"+F4+"\n";
            QVector<QStringList> dataList;
            QStringList rowdata;
            for(int i=26;i<xlsx.dimension().rowCount()+1;i++){
                rowdata.clear();
                rowdata<<xlsx.read(i,2).toString()<<xlsx.read(i,3).toString()<<xlsx.read(i,7).toString()
                      <<xlsx.read(i,8).toString()<<QString::number(xlsx.read(i,11).toDouble(),'f',2)
                     <<QString::number(xlsx.read(i,4).toDouble(),'f',2);
                dataList.append(rowdata);
            }
            table1Data=dataList;
            table();
        }
    }
}
// 表格1
void UploadFile::table()
{
    int k = 0;
    double JCV = 0;
    for(int i=0;i<table1Data.size();i++){
        QStringList rowdata = table1Data[i];
        QString cell_valueYG = rowdata[3];
        QString cell_valueJC = rowdata[2];
        if((cell_valueJC.contains("sta",Qt::CaseInsensitive)||cell_valueJC.contains("std",Qt::CaseInsensitive)||cell_valueJC.contains("标准品",Qt::CaseInsensitive))&&cell_valueYG=="ROX"){
            double cell_valueJCV = table1Data[i+3][4].toDouble();
            QString BZP6 = QString::number(cell_valueJCV,'f',4);
            double bzp6 = BZP6.toDouble();
            JCV +=bzp6;
            k++;
        }
    }
    double t = JCV/k;
    QStringList ybmsame;
    for (int i = 0; i < table1Data.size(); i++) {
        QStringList rowdata = table1Data[i];
        QString cell_value = rowdata[1];
        QString cell_value2 =  rowdata[2];
        if(ybmsame.contains(cell_value)&&!(cell_value2.contains("sta",Qt::CaseInsensitive)||cell_value2.contains("std",Qt::CaseInsensitive)||cell_value2.contains("标准品",Qt::CaseInsensitive))){

        }else if(!ybmsame.contains(cell_value)&&!(cell_value2.contains("sta",Qt::CaseInsensitive)||cell_value2.contains("std",Qt::CaseInsensitive)||cell_value2.contains("标准品",Qt::CaseInsensitive))){
            ybmsame.append(cell_value);
        }
    }
    QList<int> ybmnum;
    QList<double> AL;
    QList<double> AS;
    QList<double> Y;
    QList<double> CQ;
    for(int i=0;i<ybmsame.length();i++){
        ybmnum.append(0);
        AL.append(0);
        AS.append(0);
        Y.append(0);
        CQ.append(0);
    }
    for (int i = 0; i < table1Data.size(); i=i+4) {
        QStringList rowdata = table1Data[i];
        QString cell_value = rowdata[1];
        for(int j = 0;j<ybmsame.length();j++){
            if(cell_value==ybmsame[j]){
                double cell_valueAL = QString::number(table1Data[i+2][5].toDouble(),'f',2).toDouble();
                double cell_valueAS = QString::number(table1Data[i+1][5].toDouble(),'f',2).toDouble();
                double cell_valueY = QString::number(table1Data[i][5].toDouble(),'f',2).toDouble();
                double cell_valueCQ = QString::number(table1Data[i+3][4].toDouble(),'f',2).toDouble();
                AL[j]+=cell_valueAL;
                AS[j]+=cell_valueAS;
                Y[j]+=cell_valueY;
                CQ[j]+=cell_valueCQ;
                ybmnum[j]++;
            }
        }
    }
    for(int i=0;i < table1Data.size(); i+=4){
        for(int k = 0;k<ybmsame.length();k++){
            QString cell_value = table1Data[i][1];
            QString cell_value2 = table1Data[i][2];
            if(cell_value==ybmsame[k]&&!(cell_value2.contains("sta",Qt::CaseInsensitive)||cell_value2.contains("std",Qt::CaseInsensitive)||cell_value2.contains("标准品",Qt::CaseInsensitive))){
                double famn = QString::number(Y[k]/ybmnum[k],'f',2).toDouble();
                double vicn = QString::number(AS[k]/ybmnum[k],'f',2).toDouble();
                double roxn = QString::number(AL[k]/ybmnum[k],'f',2).toDouble();
                double cqv = QString::number(CQ[k]/ybmnum[k],'f',2).toDouble();
                datacu(i,famn,vicn,roxn,cqv,t);
                for(int l=0;l<7;l++){
                    table1Data[i+1].append(" ");
                    table1Data[i+2].append(" ");
                    table1Data[i+3].append(" ");
                }
            }
        }
        QString cell_value = table1Data[i][2];
        if(cell_value.contains("sta",Qt::CaseInsensitive)||cell_value.contains("std",Qt::CaseInsensitive)||cell_value.contains("标准品",Qt::CaseInsensitive)){
            for(int l=0;l<7;l++){
                table1Data[i].append(" ");
                table1Data[i+1].append(" ");
                table1Data[i+2].append(" ");
                table1Data[i+3].append(" ");
            }
            table1Data[i][6] = table1Data[i+1][5];
        }
    }
    int tab2row=0;
    for(int i=0;i < table1Data.size(); i+=4){
        for(int k = 0;k<ybmsame.length();k++){
            QString cell_value = table1Data[i][1];
            QString cell_value2 = table1Data[i][2];
            if(!(table1Data[i][12]=="")&&cell_value==ybmsame[k]&&!(cell_value2.contains("sta",Qt::CaseInsensitive)||cell_value2.contains("std",Qt::CaseInsensitive)||cell_value2.contains("标准品",Qt::CaseInsensitive))){
                QStringList nullist = {" "," "," "," "," "," "," "," "," "," "," "," "};
                table2Data.append(nullist);
                table2Data[tab2row][0]=table1Data[i][0];
                table2Data[tab2row][1]=table1Data[i][1];
                double famn = QString::number(Y[k]/ybmnum[k],'f',2).toDouble();
                double vicn = QString::number(AS[k]/ybmnum[k],'f',2).toDouble();
                double roxn = QString::number(AL[k]/ybmnum[k],'f',2).toDouble();
                dataca(tab2row,table1Data[i][12].toDouble(),table1Data[i][11].toDouble()
                       ,roxn,vicn,famn);
                tab2row++;
            }
        }
    }
}
// 数据计算总浓度-抑制指数
void UploadFile::datacu(int row,double famn,double vicn,double roxn,double cqv,double cqbz){
    double R1,R2,R3,X1;
    QSqlDatabase db = dbHelper::openConnection();
    QString sql=QString("SELECT Num FROM MixedJudgment WHERE Parameter='%1'")
            .arg("R1");
    QSqlQuery query(db);
    query.exec(sql);
    while (query.next()) {
        R1 = query.value("Num").toDouble();
    }
    sql=QString("SELECT Num FROM MixedJudgment WHERE Parameter='%1'")
            .arg("R2");
    query.exec(sql);
    while (query.next()) {
        R2 = query.value("Num").toDouble();
    }
    sql=QString("SELECT Num FROM MixedJudgment WHERE Parameter='%1'")
            .arg("R3");
    query.exec(sql);
    while (query.next()) {
        R3 = query.value("Num").toDouble();
    }
    sql=QString("SELECT Num FROM MixedJudgment WHERE Parameter='%1'")
            .arg("X1");
    query.exec(sql);
    while (query.next()) {
        X1 = query.value("Num").toDouble();
    }
    table1Data[row].append(QString::number(vicn,'f',2));
    if(famn==0){
        if(vicn<X1){
            table1Data[row].append("un");
            table1Data[row].append("un");
            table1Data[row].append("浓度过低无法判断");
            table1Data[row].append("-");
        }else if(vicn>=X1){
            table1Data[row].append("un");
            table1Data[row].append(QString::number(vicn,'f',2));
            table1Data[row].append("女");
            table1Data[row].append("-");
        }
    }else if(vicn/famn<R1){
        table1Data[row].append(QString::number(famn,'f',2));
        table1Data[row].append("un");
        table1Data[row].append("男");
        table1Data[row].append("-");
    }else if(vicn/famn>=R1&&vicn<=X1){
        table1Data[row].append(QString::number(famn,'f',2));
        table1Data[row].append("un");
        table1Data[row].append("男");
        table1Data[row].append("-");
    }else if(vicn/famn>=R1&&vicn/famn<R2&&vicn>X1){
        table1Data[row].append(QString::number(famn,'f',2));
        table1Data[row].append(QString::number(vicn-famn,'f',2));
        table1Data[row].append(">70%可能混");
        table1Data[row].append("1:"+QString::number((vicn-famn)/famn,'f',2));
    }else if(vicn/famn>=R2&&vicn/famn<R3&&vicn>X1){
        table1Data[row].append(QString::number(famn,'f',2));
        table1Data[row].append(QString::number(vicn-famn,'f',2));
        table1Data[row].append(">85%可能混");
        table1Data[row].append("1:"+QString::number((vicn-famn)/famn,'f',2));
    }else if(vicn/famn>=R3&&vicn>X1){
        table1Data[row].append(QString::number(famn,'f',2));
        table1Data[row].append(QString::number(vicn-famn,'f',2));
        table1Data[row].append(">95%可能混");
        table1Data[row].append("1:"+QString::number((vicn-famn)/famn,'f',2));
    }
    if(roxn==0){
        table1Data[row].append("nan");
    }else{
        table1Data[row].append(QString::number(vicn/roxn,'f',2));
    }
    table1Data[row].append(QString::number(cqv-cqbz,'f',2));
}
// 指导建议-稀释
void UploadFile::dataca(int row,double ICS,double DI,double AL,double AS,double Y){
    QMap<QString,QString> map;
    if(ische[0]=="1"){
        QSqlDatabase db = dbHelper::openConnection();
        QString sql=QString("SELECT m.SystemName,m.SystemNum from DataAnalyseConfig d,ModelConfigurationNormal m where m.ID=d.ModelGuid and d.ReagentKitType='%1' and d.ReagentKitName='%2' and d.System='%3' ;")
                .arg(types[0],names[0],volumes[0]);
        QSqlQuery query(db);
        query.exec(sql);
        while (query.next()) {
            map.insert(query.value("SystemName").toString(),query.value("SystemNum").toString());
        }
    }
    if(ische[1]=="1"){
        QSqlDatabase db = dbHelper::openConnection();
        QString sql=QString("SELECT m.SystemName,m.SystemNum from DataAnalyseConfig d,ModelConfigurationY m where m.ID=d.ModelGuid and d.ReagentKitType='%1' and d.ReagentKitName='%2' and d.System='%3' ;")
                .arg(types[1],names[1],volumes[1]);
        QSqlQuery query(db);
        query.exec(sql);
        while (query.next()) {
            map.insert(query.value("SystemName").toString(),query.value("SystemNum").toString());
        }
    }
    if(ische[2]=="1"){
        QSqlDatabase db = dbHelper::openConnection();
        QString sql=QString("SELECT m.SystemName,m.SystemNum from DataAnalyseConfig d,ModelConfigurationMini m where m.ID=d.ModelGuid and d.ReagentKitType='%1' and d.ReagentKitName='%2' and d.System='%3' ;")
                .arg(types[2],names[2],volumes[2]);
        QSqlQuery query(db);
        query.exec(sql);
        while (query.next()) {
            map.insert(query.value("SystemName").toString(),query.value("SystemNum").toString());
        }
    }

    if(ische[0]=="1"&&volumes[0]=="10"){
        map.insert("Da",QString::number(0.3*(1+(DI-1/DI))));
        map.insert("Db",QString::number(0.3*(1+(DI-1/DI))));
        map.insert("Dc",QString::number(0.3*(1+(DI-1/DI))));
        map.insert("Dd",QString::number(0.3*(1+(DI-1/DI))));
        map.insert("De",QString::number(0.3*(1+(DI-1/DI))));
        map.insert("MXa",QString::number(1.5/DI*(1+(DI-1)/DI)));
        map.insert("MXb",QString::number(1.5/DI*(1+(DI-1)/DI)));
        map.insert("MXc",QString::number(1.5/DI*(1+(DI-1)/DI)));
        map.insert("MXd",QString::number(1.5/DI*(1+(DI-1)/DI)));
        map.insert("MXe",QString::number(1.5/DI*(1+(DI-1)/DI)));
        double ASN2=map.value("Md").toDouble()/map.value("Mv").toDouble();
        double ASN3=map.value("Md").toDouble()/4;
        double ASN4=map.value("Md").toDouble()/3;
        double ASN5=map.value("Md").toDouble()/2;
        double ASN6=map.value("Mx").toDouble();
        double d = AL;
        double ALN1 = map.value("La").toDouble();
        double ALN2 = map.value("Da").toDouble()/map.value("Mv").toDouble();
        double ALN3 = map.value("Da").toDouble()/4;
        double ALN4 = map.value("Da").toDouble()/3;
        double ALN5 = map.value("Da").toDouble()/2;
        double ALN6 = map.value("MXa").toDouble();
        double ALN7 = map.value("Lb").toDouble();
        double ALN8 = map.value("Db").toDouble()/map.value("Mv").toDouble();
        double ALN9 = map.value("Db").toDouble()/4;
        double ALN10 = map.value("Db").toDouble()/3;
        double ALN11 = map.value("Db").toDouble()/2;
        double ALN12 = map.value("MXb").toDouble();
        double ALN13 = map.value("Lc").toDouble();
        double ALN14 = map.value("Dc").toDouble()/map.value("Mv").toDouble();
        double ALN15 = map.value("Dc").toDouble()/4;
        double ALN16 = map.value("Dc").toDouble()/3;
        double ALN17 = map.value("Dc").toDouble()/2;
        double ALN18 = map.value("MXc").toDouble();
        double ALN19 = map.value("Ld").toDouble();
        double ALN20 = map.value("Dd").toDouble()/map.value("Mv").toDouble();
        double ALN21 = map.value("Dd").toDouble()/4;
        double ALN22 = map.value("Dd").toDouble()/3;
        double ALN23 = map.value("Dd").toDouble()/2;
        double ALN24 = map.value("MXd").toDouble();
        double ALN25 = map.value("Le").toDouble();
        double ALN26 = map.value("De").toDouble()/map.value("Mv").toDouble();
        double ALN27 = map.value("De").toDouble()/4;
        double ALN28 = map.value("De").toDouble()/3;
        double ALN29 = map.value("De").toDouble()/2;
        double ALN30 = map.value("MXe").toDouble();
        table2Data[row][2] = "常STR";
        if(ICS>=2){
            table2Data[row][2] = map.value("检测方案");
            table2Data[row][3] = "无";
            table2Data[row][11] = map.value("备注");
        }if(ICS<2&&DI<1.5){
            if(AS<ASN2){
                table2Data[row][10] = map.value("Mv")+"ul";
                table2Data[row][3] = "无";
            }else if(AS>=ASN2&&AS<=ASN3){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(AS>ASN3&&AS<=ASN4){
                table2Data[row][10] = "3ul";
                table2Data[row][3] = "无";
            }else if(AS>ASN4&&AS<=ASN5){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(AS>ASN5&&AS<=ASN6){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(AS>ASN6){
                table2Data[row][10] = "稀释至AS"+QString::number(map.value("Md").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(AS/(map.value("Md").toDouble()/2));
            }

        }else if(ICS<2&&DI>=1.5&&DI<=4){
            if(d<ALN1){
                table2Data[row][2] = "mini-STR";
                table2Data[row][3] = "无";
                miniSTRfl=true;
            }else if(d>=ALN1&&d<=ALN2){
                table2Data[row][10] = map.value("Mv")+"ul";
                table2Data[row][3] = "无";
            }else if(d>ALN2&&d<=ALN3){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>ALN3&&d<=ALN4){
                table2Data[row][10] = "3ul";
                table2Data[row][3] = "无";
            }else if(d>ALN4&&d<=ALN5){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN5&&d<=ALN6){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN6){
                table2Data[row][10] = "稀释至AL"+QString::number(map.value("Da").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(AL/(map.value("Da").toDouble()/2));
            }
        }else if(ICS<2&&DI>4&&DI<=12){
            if(d<ALN7){
                table2Data[row][2] = "mini-STR";
                table2Data[row][3] = "无";
                miniSTRfl=true;
            }else if(d>=ALN7&&d<=ALN8){
                table2Data[row][10] = map.value("Mv")+"ul";
                table2Data[row][3] = "无";
            }else if(d>ALN8&&d<=ALN9){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>ALN9&&d<=ALN10){
                table2Data[row][10] = "3ul";
                table2Data[row][3] = "无";
            }else if(d>ALN10&&d<=ALN11){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN11&&d<=ALN12){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN12){
                table2Data[row][10] = "稀释至AL"+QString::number(map.value("Db").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(AL/(map.value("Db").toDouble()/2));
            }
        }else if(ICS<2&&DI>12&&DI<=20){
            if(d<ALN13){
                table2Data[row][2] = "mini-STR";
                table2Data[row][3] = "无";
                miniSTRfl=true;
            }else if(d>=ALN13&&d<=ALN14){
                table2Data[row][10] = map.value("Mv")+"ul";
                table2Data[row][3] = "无";
            }else if(d>ALN14&&d<=ALN15){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>ALN15&&d<=ALN16){
                table2Data[row][10] = "3ul";
                table2Data[row][3] = "无";
            }else if(d>ALN16&&d<=ALN17){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN17&&d<=ALN18){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN18){
                table2Data[row][10] = "稀释至AL"+QString::number(map.value("Dc").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(AL/(map.value("Dc").toDouble()/2));
            }
        }else if(ICS<2&&DI>20&&DI<=35){
            if(d<ALN19){
                table2Data[row][2] = "mini-STR";
                table2Data[row][3] = "无";
                miniSTRfl=true;
            }else if(d>=ALN19&&d<=ALN20){
                table2Data[row][10] = map.value("Mv")+"ul";
                table2Data[row][3] = "无";
            }else if(d>ALN20&&d<=ALN21){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>ALN21&&d<=ALN22){
                table2Data[row][10] = "3ul";
                table2Data[row][3] = "无";
            }else if(d>ALN22&&d<=ALN23){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN23&&d<=ALN24){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN24){
                table2Data[row][10] = "稀释至AL"+QString::number(map.value("Dd").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(AL/(map.value("Dd").toDouble()/2));
            }
        }else if(ICS<2&&DI>35&&DI<=80){
            if(d<ALN25){
                table2Data[row][2] = "mini-STR";
                table2Data[row][3] = "无";
                miniSTRfl=true;
            }else if(d>=ALN25&&d<=ALN26){
                table2Data[row][10] = map.value("Mv")+"ul";
                table2Data[row][3] = "无";
            }else if(d>ALN26&&d<=ALN27){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>ALN27&&d<=ALN28){
                table2Data[row][10] = "3ul";
                table2Data[row][3] = "无";
            }else if(d>ALN28&&d<=ALN29){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN29&&d<=ALN30){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN30){
                table2Data[row][10] = "稀释至AL"+QString::number(map.value("De").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(AL/(map.value("De").toDouble()/2));
            }
        }else if(ICS<2&&(DI>80||DI==0)){
            if(map.value("Ni").toInt()==0){
                table2Data[row][10] = map.value("Mv")+"ul";
                table2Data[row][3] = "无";
            }if(map.value("Ni").toInt()==0){
                table2Data[row][2] = "mini-STR";
                table2Data[row][3] = "无";
                miniSTRfl=true;
            }
        }else{
            table2Data[row][2] = "常STR";
            table2Data[row][10] = map.value("Mv")+"ul";
            table2Data[row][3] = "无";
        }
    }
    if(ische[0]=="1"&&volumes[0]=="15"){
        map.insert("Da*",QString::number(0.3*(1+(DI-1/DI))));
        map.insert("Db*",QString::number(0.3*(1+(DI-1/DI))));
        map.insert("Dc*",QString::number(0.3*(1+(DI-1/DI))));
        map.insert("Dd*",QString::number(0.3*(1+(DI-1/DI))));
        map.insert("De*",QString::number(0.3*(1+(DI-1/DI))));
        map.insert("MXa*",QString::number(1.5/DI*(1+(DI-1)/DI)));
        map.insert("MXb*",QString::number(1.5/DI*(1+(DI-1)/DI)));
        map.insert("MXc*",QString::number(1.5/DI*(1+(DI-1)/DI)));
        map.insert("MXd*",QString::number(1.5/DI*(1+(DI-1)/DI)));
        map.insert("MXe*",QString::number(1.5/DI*(1+(DI-1)/DI)));
        double ASN2=map.value("Md*").toDouble()/map.value("Mv*").toDouble();
        double ASN3=map.value("Md*").toDouble()/15;
        double ASN4=map.value("Md*").toDouble()/12;
        double ASN5=map.value("Md*").toDouble()/10;
        double ASN6=map.value("Md*").toDouble()/8;
        double ASN7=map.value("Md*").toDouble()/6;
        double ASN8=map.value("Md*").toDouble()/4;
        double ASN9=map.value("Md*").toDouble()/2;
        double ASN10=map.value("Mx*").toDouble();
        double d = AL;
        double ALN1 = map.value("La*").toDouble();
        double ALN2 = map.value("Da*").toDouble()/map.value("Mv*").toDouble();
        double ALN3 = map.value("Da*").toDouble()/15;
        double ALN4 = map.value("Da*").toDouble()/12;
        double ALN5 = map.value("Da*").toDouble()/10;
        double ALN6 = map.value("Da*").toDouble()/8;
        double ALN7 = map.value("Da*").toDouble()/6;
        double ALN8 = map.value("Da*").toDouble()/4;
        double ALN9 = map.value("Da*").toDouble()/2;
        double ALN10 = map.value("MXa*").toDouble();
        double ALN11 = map.value("Lb*").toDouble();
        double ALN12 = map.value("Db*").toDouble()/map.value("Mv*").toDouble();
        double ALN13 = map.value("Db*").toDouble()/15;
        double ALN14 = map.value("Db*").toDouble()/12;
        double ALN15 = map.value("Db*").toDouble()/10;
        double ALN16 = map.value("Db*").toDouble()/8;
        double ALN17 = map.value("Db*").toDouble()/6;
        double ALN18 = map.value("Db*").toDouble()/4;
        double ALN19 = map.value("Db*").toDouble()/2;
        double ALN20 = map.value("MXb*").toDouble();
        double ALN21 = map.value("Lc*").toDouble();
        double ALN22 = map.value("Dc*").toDouble()/map.value("Mv*").toDouble();
        double ALN23 = map.value("Dc*").toDouble()/15;
        double ALN24 = map.value("Dc*").toDouble()/12;
        double ALN25 = map.value("Dc*").toDouble()/10;
        double ALN26 = map.value("Dc*").toDouble()/8;
        double ALN27 = map.value("Dc*").toDouble()/6;
        double ALN28 = map.value("Dc*").toDouble()/4;
        double ALN29 = map.value("Dc*").toDouble()/2;
        double ALN30 = map.value("MXc*").toDouble();
        double ALN31 = map.value("Ld*").toDouble();
        double ALN32 = map.value("Dd*").toDouble()/map.value("Mv*").toDouble();
        double ALN33 = map.value("Dd*").toDouble()/15;
        double ALN34 = map.value("Dd*").toDouble()/12;
        double ALN35 = map.value("Dd*").toDouble()/10;
        double ALN36 = map.value("Dd*").toDouble()/8;
        double ALN37 = map.value("Dd*").toDouble()/6;
        double ALN38 = map.value("Dd*").toDouble()/4;
        double ALN39 = map.value("Dd*").toDouble()/2;
        double ALN40 = map.value("MXd*").toDouble();
        double ALN41 = map.value("Le*").toDouble();
        double ALN42 = map.value("De*").toDouble()/map.value("Mv*").toDouble();
        double ALN43 = map.value("De*").toDouble()/15;
        double ALN44 = map.value("De*").toDouble()/12;
        double ALN45 = map.value("De*").toDouble()/10;
        double ALN46 = map.value("De*").toDouble()/8;
        double ALN47 = map.value("De*").toDouble()/6;
        double ALN48 = map.value("De*").toDouble()/4;
        double ALN49 = map.value("De*").toDouble()/2;
        double ALN50 = map.value("MXe*").toDouble();
        table2Data[row][2] = "常STR";
        if(ICS>=2){
            table2Data[row][2] = map.value("检测方案");
            table2Data[row][3] = "无";
            table2Data[row][11] = map.value("备注");
        }if(ICS<2&&DI<1.5){
            if(AS<ASN2){
                table2Data[row][10] = map.value("Mv*");
                table2Data[row][3] = "无";
            }else if(AS>=ASN2&&AS<=ASN3){
                table2Data[row][10] = "15ul";
                table2Data[row][3] = "无";
            }else if(AS>ASN3&&AS<=ASN4){
                table2Data[row][10] = "12ul";
                table2Data[row][3] = "无";
            }else if(AS>ASN4&&AS<=ASN5){
                table2Data[row][10] = "10ul";
                table2Data[row][3] = "无";
            }else if(AS>ASN5&&AS<=ASN6){
                table2Data[row][10] = "8ul";
                table2Data[row][3] = "无";
            }else if(AS>ASN6&&AS<=ASN7){
                table2Data[row][10] = "6ul";
                table2Data[row][3] = "无";
            }else if(AS>ASN7&&AS<=ASN8){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(AS>ASN8&&AS<=ASN9){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(AS>ASN9&&AS<=ASN10){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(AS>ASN10){
                table2Data[row][10] = "稀释至AS"+QString::number(map.value("Md*").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(AS/(map.value("Md*").toDouble()/2));
            }

        }else if(ICS<2&&DI>=1.5&&DI<=4){
            if(d<ALN1){
                table2Data[row][2] = "mini-STR";
                table2Data[row][3] = "无";
            }else if(d>=ALN1&&d<=ALN2){
                table2Data[row][10] = map.value("Mv*");
                table2Data[row][3] = "无";
            }else if(d>ALN2&&d<=ALN3){
                table2Data[row][10] = "15ul";
                table2Data[row][3] = "无";
            }else if(d>ALN3&&d<=ALN4){
                table2Data[row][10] = "12ul";
                table2Data[row][3] = "无";
            }else if(d>ALN4&&d<=ALN5){
                table2Data[row][10] = "10ul";
                table2Data[row][3] = "无";
            }else if(d>ALN5&&d<=ALN6){
                table2Data[row][10] = "8ul";
                table2Data[row][3] = "无";
            }else if(d>ALN6&&d<=ALN7){
                table2Data[row][10] = "6ul";
                table2Data[row][3] = "无";
            }else if(d>ALN7&&d<=ALN8){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>ALN8&&d<=ALN9){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN9&&d<=ALN10){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN10){
                table2Data[row][10] = "稀释至AS"+QString::number(map.value("Da*").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(AS/(map.value("Da*").toDouble()/2));
            }
        }else if(ICS<2&&DI>4&&DI<=12){
            if(d<ALN11){
                table2Data[row][2] = "mini-STR";
                table2Data[row][3] = "无";
            }else if(d>=ALN11&&d<=ALN12){
                table2Data[row][10] = map.value("Mv*");
                table2Data[row][3] = "无";
            }else if(d>ALN12&&d<=ALN13){
                table2Data[row][10] = "15ul";
                table2Data[row][3] = "无";
            }else if(d>ALN13&&d<=ALN14){
                table2Data[row][10] = "12ul";
                table2Data[row][3] = "无";
            }else if(d>ALN14&&d<=ALN15){
                table2Data[row][10] = "10ul";
                table2Data[row][3] = "无";
            }else if(d>ALN15&&d<=ALN16){
                table2Data[row][10] = "8ul";
                table2Data[row][3] = "无";
            }else if(d>ALN16&&d<=ALN17){
                table2Data[row][10] = "6ul";
                table2Data[row][3] = "无";
            }else if(d>ALN17&&d<=ALN18){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>ALN18&&d<=ALN19){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN19&&d<=ALN20){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN20){
                table2Data[row][10] = "稀释至AS"+QString::number(map.value("Db*").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(AS/(map.value("Db*").toDouble()/2));
            }
        }else if(ICS<2&&DI>12&&DI<=20){
            if(d<ALN21){
                table2Data[row][2] = "mini-STR";
                table2Data[row][3] = "无";
            }else if(d>=ALN21&&d<=ALN22){
                table2Data[row][10] = map.value("Mv*");
                table2Data[row][3] = "无";
            }else if(d>ALN22&&d<=ALN23){
                table2Data[row][10] = "15ul";
                table2Data[row][3] = "无";
            }else if(d>ALN23&&d<=ALN24){
                table2Data[row][10] = "12ul";
                table2Data[row][3] = "无";
            }else if(d>ALN24&&d<=ALN25){
                table2Data[row][10] = "8ul";
                table2Data[row][3] = "无";
            }else if(d>ALN25&&d<=ALN26){
                table2Data[row][10] = "6ul";
                table2Data[row][3] = "无";
            }else if(d>ALN26&&d<=ALN27){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>ALN27&&d<=ALN28){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN28&&d<=ALN29){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN29&&d<=ALN30){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN30){
                table2Data[row][10] = "稀释至AS"+QString::number(map.value("Dc*").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(AS/(map.value("Dc*").toDouble()/2));
            }
        }else if(ICS<2&&DI>20&&DI<=35){
            if(d<ALN31){
                table2Data[row][2] = "mini-STR";
                table2Data[row][3] = "无";
            }else if(d>=ALN31&&d<=ALN32){
                table2Data[row][10] = map.value("Mv*");
                table2Data[row][3] = "无";
            }else if(d>ALN32&&d<=ALN33){
                table2Data[row][10] = "15ul";
                table2Data[row][3] = "无";
            }else if(d>ALN33&&d<=ALN34){
                table2Data[row][10] = "12ul";
                table2Data[row][3] = "无";
            }else if(d>ALN34&&d<=ALN35){
                table2Data[row][10] = "10ul";
                table2Data[row][3] = "无";
            }else if(d>ALN35&&d<=ALN36){
                table2Data[row][10] = "8ul";
                table2Data[row][3] = "无";
            }else if(d>ALN36&&d<=ALN37){
                table2Data[row][10] = "6ul";
                table2Data[row][3] = "无";
            }else if(d>ALN37&&d<=ALN38){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>ALN38&&d<=ALN39){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN39&&d<=ALN40){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN40){
                table2Data[row][10] = "稀释至AS"+QString::number(map.value("Dd*").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(AS/(map.value("Dd*").toDouble()/2));
            }
        }else if(ICS<2&&DI>35&&DI<=80){
            if(d<ALN41){
                table2Data[row][2] = "mini-STR";
                table2Data[row][3] = "无";
            }else if(d>=ALN41&&d<=ALN42){
                table2Data[row][10] = map.value("Mv*");
                table2Data[row][3] = "无";
            }else if(d>ALN42&&d<=ALN43){
                table2Data[row][10] = "15ul";
                table2Data[row][3] = "无";
            }else if(d>ALN43&&d<=ALN44){
                table2Data[row][10] = "12ul";
                table2Data[row][3] = "无";
            }else if(d>ALN44&&d<=ALN45){
                table2Data[row][10] = "10ul";
                table2Data[row][3] = "无";
            }else if(d>ALN45&&d<=ALN46){
                table2Data[row][10] = "8ul";
                table2Data[row][3] = "无";
            }else if(d>ALN46&&d<=ALN47){
                table2Data[row][10] = "6ul";
                table2Data[row][3] = "无";
            }else if(d>ALN47&&d<=ALN48){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>ALN48&&d<=ALN49){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN49&&d<=ALN50){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>ALN50){
                table2Data[row][10] = "稀释至AS"+QString::number(map.value("De*").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(AS/(map.value("De*").toDouble()/2));
            }
        }else if(ICS<2&&(DI>80||DI==0)){
            if(map.value("Ni").toInt()==0){
                table2Data[row][10] = map.value("Mv*");
                table2Data[row][3] = "无";
            }if(map.value("Ni").toInt()==0){
                table2Data[row][2] = "mini-STR";
                table2Data[row][3] = "无";
            }
        }else{
            table2Data[row][10] = map.value("Mv*");
            table2Data[row][3] = "无";
        }
    }
    if(YSTRfl&&ische[1]=="1"){
        map.insert("YDa",QString::number(1.1*(1+(DI-1)/DI)));
        map.insert("YDb",QString::number(1.1*(1+(DI-1)/DI)));
        map.insert("YDc",QString::number(1.1*(1+(DI-1)/DI)));
        map.insert("YDd",QString::number(1.1*(1+(DI-1)/DI)));
        map.insert("YDe",QString::number(1.1*(1+(DI-1)/DI)));
        map.insert("YXa",QString::number(1.2*(1+(DI-1)/DI)));
        map.insert("YXb",QString::number(1.2*(1+(DI-1)/DI)));
        map.insert("YXc",QString::number(1.2*(1+(DI-1)/DI)));
        map.insert("YXd",QString::number(1.2*(1+(DI-1)/DI)));
        map.insert("YXe",QString::number(1.2*(1+(DI-1)/DI)));
        double d = Y;
        double Y1 = map.value("Yd").toDouble()/map.value("Yv").toDouble();
        double Y2 = map.value("Yd").toDouble()/4;
        double Y3 = map.value("Yd").toDouble()/3;
        double Y4 = map.value("Yd").toDouble()/2;
        double Y5 = map.value("Yx").toDouble();
        double Y6 = map.value("YDa").toDouble()/map.value("Yv").toDouble();
        double Y7 = map.value("YDa").toDouble()/4;
        double Y8 = map.value("YDa").toDouble()/3;
        double Y9 = map.value("YDa").toDouble()/2;
        double Y10 = map.value("YDa").toDouble()/1.5;
        double Y11 = map.value("YXa").toDouble();
        double Y12 = map.value("YDb").toDouble()/map.value("Yv").toDouble();
        double Y13 = map.value("YDb").toDouble()/4;
        double Y14 = map.value("YDb").toDouble()/3;
        double Y15 = map.value("YDb").toDouble()/2;
        double Y16 = map.value("YDb").toDouble()/1.5;
        double Y17 = map.value("YXb").toDouble();
        double Y18 = map.value("YDc").toDouble()/map.value("Yv").toDouble();
        double Y19 = map.value("YDc").toDouble()/4;
        double Y20 = map.value("YDc").toDouble()/3;
        double Y21 = map.value("YDc").toDouble()/2;
        double Y22 = map.value("YDc").toDouble()/1.5;
        double Y23 = map.value("YXc").toDouble();
        double Y24 = map.value("YDd").toDouble()/map.value("Yv").toDouble();
        double Y25 = map.value("YDd").toDouble()/4;
        double Y26 = map.value("YDd").toDouble()/3;
        double Y27 = map.value("YDd").toDouble()/2;
        double Y28 = map.value("YDd").toDouble()/1.5;
        double Y29 = map.value("YXd").toDouble();
        double Y30 = map.value("YDe").toDouble()/map.value("Yv").toDouble();
        double Y31 = map.value("YDe").toDouble()/4;
        double Y32 = map.value("YDe").toDouble()/3;
        double Y33 = map.value("YDe").toDouble()/2;
        double Y34 = map.value("YDe").toDouble()/1.5;
        double Y35 = map.value("YXe").toDouble();
        table2Data[row][2] = "Y-STR";
        if(DI<=2){
            if(d<Y1){
                table2Data[row][10] = map.value("Yv")+"ul";
                table2Data[row][3] = "无";
            }else if(d>=Y1&&d<=Y2){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>Y2&&d<=Y3){
                table2Data[row][10] = "3ul";
                table2Data[row][3] = "无";
            }else if(d>Y3&&d<=Y4){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>Y4&&d<=Y5){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>Y5){
                table2Data[row][10] = "稀释至Y"+QString::number(map.value("Yd*").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(Y/(map.value("Yd*").toDouble()/2));
            }
        }else if(DI>2&&DI<=4){
            if(d<Y6){
                table2Data[row][10] = map.value("Yv")+"ul";
                table2Data[row][3] = "无";
            }else if(d>=Y6&&d<=Y7){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>Y7&&d<=Y8){
                table2Data[row][10] = "3ul";
                table2Data[row][3] = "无";
            }else if(d>Y8&&d<=Y9){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>Y9&&d<=Y10){
                table2Data[row][10] = "1.5ul";
                table2Data[row][3] = "无";
            }else if(d>Y10&&d<=Y11){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>Y11){
                table2Data[row][10] = "稀释至Y"+QString::number(map.value("YDa*").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(Y/(map.value("YDa*").toDouble()/2));
            }
        }else if(DI>4&&DI<=12){
            if(d<Y12){
                table2Data[row][10] = map.value("Yv")+"ul";
                table2Data[row][3] = "无";
            }else if(d>=Y12&&d<=Y13){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>Y13&&d<=Y14){
                table2Data[row][10] = "3ul";
                table2Data[row][3] = "无";
            }else if(d>Y14&&d<=Y15){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>Y15&&d<=Y16){
                table2Data[row][10] = "1.5ul";
                table2Data[row][3] = "无";
            }else if(d>Y16&&d<=Y17){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>Y17){
                table2Data[row][10] = "稀释至Y"+QString::number(map.value("YDb*").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(Y/(map.value("YDb*").toDouble()/2));
            }
        }else if(DI>12&&DI<=20){
            if(d<Y18){
                table2Data[row][10] = map.value("Yv")+"ul";
                table2Data[row][3] = "无";
            }else if(d>=Y18&&d<=Y19){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>Y19&&d<=Y20){
                table2Data[row][10] = "3ul";
                table2Data[row][3] = "无";
            }else if(d>Y20&&d<=Y21){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>Y21&&d<=Y22){
                table2Data[row][10] = "1.5ul";
                table2Data[row][3] = "无";
            }else if(d>Y22&&d<=Y23){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>Y23){
                table2Data[row][10] = "稀释至Y"+QString::number(map.value("YDc*").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(Y/(map.value("YDc*").toDouble()/2));
            }
        }else if(DI>20&&DI<=35){
            if(d<Y24){
                table2Data[row][10] = map.value("Yv")+"ul";
                table2Data[row][3] = "无";
            }else if(d>=Y24&&d<=Y25){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>Y25&&d<=Y26){
                table2Data[row][10] = "3ul";
                table2Data[row][3] = "无";
            }else if(d>Y26&&d<=Y27){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>Y27&&d<=Y28){
                table2Data[row][10] = "1.5ul";
                table2Data[row][3] = "无";
            }else if(d>Y28&&d<=Y29){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>Y29){
                table2Data[row][10] = "稀释至Y"+QString::number(map.value("YDd*").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(Y/(map.value("YDd*").toDouble()/2));
            }
        }else if(DI>35&&DI<=80){
            if(d<Y30){
                table2Data[row][10] = map.value("Yv")+"ul";
                table2Data[row][3] = "无";
            }else if(d>=Y30&&d<=Y31){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>Y31&&d<=Y32){
                table2Data[row][10] = "3ul";
                table2Data[row][3] = "无";
            }else if(d>Y32&&d<=Y33){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>Y33&&d<=Y34){
                table2Data[row][10] = "1.5ul";
                table2Data[row][3] = "无";
            }else if(d>Y34&&d<=Y35){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>Y35){
                table2Data[row][10] = "稀释至Y"+QString::number(map.value("YDe*").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(Y/(map.value("YDe*").toDouble()/2));
            }
        }else if(DI>80||DI==0){
            if(map.value("Ni").toInt()==1){
                table2Data[row][10] = map.value("Yv")+"ul";
                table2Data[row][3] = "无";
            }else if(map.value("Ni").toInt()==0){
                table2Data[row][10] = map.value("");
                table2Data[row][3] = "无";
            }
        }else{
            table2Data[row][10] = map.value("");
            table2Data[row][3] = "无";
        }
    }
    if(miniSTRfl&&ische[2]=="1"&&table2Data[row][2]=="mini-STR"){
        map.insert("Ia",QString::number(0.25*(1+(DI-1)/DI)));
        map.insert("Ib",QString::number(0.25*(1+(DI-1)/DI)));
        map.insert("Ic",QString::number(0.25*(1+(DI-1)/DI)));
        map.insert("Id",QString::number(0.25*(1+(DI-1)/DI)));
        map.insert("Ie",QString::number(0.25*(1+(DI-1)/DI)));
        map.insert("IXa",QString::number(1.2*(1+(DI-1)/DI)));
        map.insert("IXb",QString::number(1.2*(1+(DI-1)/DI)));
        map.insert("IXc",QString::number(1.2*(1+(DI-1)/DI)));
        map.insert("IXd",QString::number(1.2*(1+(DI-1)/DI)));
        map.insert("IXe",QString::number(1.2*(1+(DI-1)/DI)));
        double d = AL;
        double M1 = map.value("Is").toDouble()/map.value("Iv").toDouble();
        double M2 = map.value("Is").toDouble()/4;
        double M3 = map.value("Is").toDouble()/3;
        double M4 = map.value("Is").toDouble()/2;
        double M5 = map.value("Ix").toDouble();
        double M6 = map.value("Ia").toDouble()/map.value("Iv").toDouble();
        double M7 = map.value("Ia").toDouble()/4;
        double M8 = map.value("Ia").toDouble()/3;
        double M9 = map.value("Ia").toDouble()/2;
        double M10 = map.value("IXa").toDouble();
        double M11 = map.value("Ib").toDouble()/map.value("Iv").toDouble();
        double M12 = map.value("Ib").toDouble()/4;
        double M13 = map.value("Ib").toDouble()/3;
        double M14 = map.value("Ib").toDouble()/2;
        double M15 = map.value("IXb").toDouble();
        double M16 = map.value("Ic").toDouble()/map.value("Iv").toDouble();
        double M17 = map.value("Ic").toDouble()/4;
        double M18 = map.value("Ic").toDouble()/3;
        double M19 = map.value("Ic").toDouble()/2;
        double M20 = map.value("IXc").toDouble();
        double M21 = map.value("Id").toDouble()/map.value("Iv").toDouble();
        double M22 = map.value("Id").toDouble()/4;
        double M23 = map.value("Id").toDouble()/3;
        double M24 = map.value("Id").toDouble()/2;
        double M25 = map.value("IXd").toDouble();
        double M26 = map.value("Ie").toDouble()/map.value("Iv").toDouble();
        double M27 = map.value("Ie").toDouble()/4;
        double M28 = map.value("Ie").toDouble()/3;
        double M29 = map.value("Ie").toDouble()/2;
        double M30 = map.value("IXe").toDouble();
        table2Data[row][2] = "mini-STR";
        if(DI<1.5){
            if(AS<M1){
                table2Data[row][10] = map.value("Iv")+"ul";
                table2Data[row][3] = "无";
            }else if(AS>=M1&&AS<=M2){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(AS>M2&&AS<=M3){
                table2Data[row][10] = "3ul";
                table2Data[row][3] = "无";
            }else if(AS>M3&&AS<=M4){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(AS>M4&&AS<=M5){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(AS>M5){
                table2Data[row][10] = "稀释至AS"+QString::number(map.value("Is*").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(AS/(map.value("Is*").toDouble()/2));
            }
        }else if(DI>=1.5&&DI<=4){
            if(d<M6){
                table2Data[row][10] = map.value("Iv")+"ul";
                table2Data[row][3] = "无";
            }else if(d>=M6&&d<=M7){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>M7&&d<=M8){
                table2Data[row][10] = "3ul";
                table2Data[row][3] = "无";
            }else if(d>M8&&d<=M9){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>M9&&d<=M10){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>M10){
                table2Data[row][10] = "稀释至AS"+QString::number(map.value("Ia*").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(AS/(map.value("Ia*").toDouble()/2));
            }
        }else if(DI>4&&DI<=12){
            if(d<M11){
                table2Data[row][10] = map.value("Iv")+"ul";
                table2Data[row][3] = "无";
            }else if(d>=M11&&d<=M12){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>M12&&d<=M13){
                table2Data[row][10] = "3ul";
                table2Data[row][3] = "无";
            }else if(d>M13&&d<=M14){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>M14&&d<=M15){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>M15){
                table2Data[row][10] = "稀释至AS"+QString::number(map.value("Ib*").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(AS/(map.value("Ib*").toDouble()/2));
            }
        }else if(DI>12&&DI<=20){
            if(d<M16){
                table2Data[row][10] = map.value("Iv")+"ul";
                table2Data[row][3] = "无";
            }else if(d>=M16&&d<=M17){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>M17&&d<=M18){
                table2Data[row][10] = "3ul";
                table2Data[row][3] = "无";
            }else if(d>M18&&d<=M19){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>M19&&d<=M20){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>M20){
                table2Data[row][10] = "稀释至AS"+QString::number(map.value("Ic*").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(AS/(map.value("Ic*").toDouble()/2));
            }
        }else if(DI>20&&DI<=35){
            if(d<M21){
                table2Data[row][10] = map.value("Iv")+"ul";
                table2Data[row][3] = "无";
            }else if(d>=M21&&d<=M22){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>M22&&d<=M23){
                table2Data[row][10] = "3ul";
                table2Data[row][3] = "无";
            }else if(d>M23&&d<=M24){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>M24&&d<=M25){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>M25){
                table2Data[row][10] = "稀释至AS"+QString::number(map.value("Id*").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(AS/(map.value("Id*").toDouble()/2));
            }
        }else if(DI>35&&DI<=80){
            if(d<M26){
                table2Data[row][10] = map.value("Iv")+"ul";
                table2Data[row][3] = "无";
            }else if(d>=M26&&d<=M27){
                table2Data[row][10] = "4ul";
                table2Data[row][3] = "无";
            }else if(d>M27&&d<=M28){
                table2Data[row][10] = "3ul";
                table2Data[row][3] = "无";
            }else if(d>M28&&d<=M29){
                table2Data[row][10] = "2ul";;
                table2Data[row][3] = "无";
            }else if(d>M29&&d<=M30){
                table2Data[row][10] = "1ul";;
                table2Data[row][3] = "无";
            }else if(d>M30){
                table2Data[row][10] = "稀释至AS"+QString::number(map.value("Ie*").toDouble()/2)+"ng/ul上样2ul";
                table2Data[row][3] = QString::number(AS/(map.value("Ie*").toDouble()/2));
            }
        }else if(DI>80||DI==0){
            table2Data[row][10] = map.value("Iv")+"ul";
            table2Data[row][3] = "无";
        }else{
            table2Data[row][10] = map.value("Iv")+"ul";
            table2Data[row][3] = "无";
        }
    }
    xsui(row,table2Data[row][2],5);
    miniSTRfl=false;
}
// 稀释方案
void UploadFile::xsui(int row,QString type,int tx){
    QString valt2 = table2Data[row][3];
    if(!valt2.isNull()){
        if(type=="常STR"){
            if(table2Data[row][3]=="无"){
                table2Data[row][4] = "无";
                table2Data[row][5] = "无";
                table2Data[row][6] = "无";
                table2Data[row][7] = "无";
                table2Data[row][8] = "无";
                table2Data[row][9] = "无";
            }else if(table2Data[row][3].toInt()<=100){
                table2Data[row][4] = table2Data[row][3];
                table2Data[row][5] = QString::number(tx,'f',2);
                table2Data[row][6] = QString::number(tx*table2Data[row][3].toDouble()-tx,'f',2);
                table2Data[row][7] = "无";
                table2Data[row][8] = "无";
                table2Data[row][9] = "无";
            }else if(table2Data[row][3].toInt()<=1000&&table2Data[row][3].toInt()>100){
                table2Data[row][4] = "20";
                table2Data[row][5] = QString::number(tx,'f',2);
                table2Data[row][6] = QString::number(tx*20-tx,'f',2);
                table2Data[row][7] = QString::number(table2Data[row][3].toDouble()/20,'f',2);
                table2Data[row][8] = QString::number(tx,'f',2);
                table2Data[row][9] = QString::number(tx*table2Data[row][3].toDouble()/20-tx,'f',2);
            }else if(table2Data[row][3].toInt()>1000){
                table2Data[row][4] = "50";
                table2Data[row][5] = QString::number(tx,'f',2);
                table2Data[row][6] = QString::number(tx*50-tx,'f',2);
                table2Data[row][7] = QString::number(table2Data[row][3].toDouble()/50,'f',2);
                table2Data[row][8] = QString::number(tx,'f',2);
                table2Data[row][9] = QString::number(tx*table2Data[row][3].toDouble()/50-tx,'f',2);
            }
        }else if(type=="Y-STR"){
            if(table2Data[row][3]=="无"){
                table2Data[row][4] = "无";
                table2Data[row][5] = "无";
                table2Data[row][6] = "无";
                table2Data[row][7] = "无";
                table2Data[row][8] = "无";
                table2Data[row][9] = "无";
            }else if(table2Data[row][3].toInt()<=100){
                table2Data[row][4] = table2Data[row][3];
                table2Data[row][5] = QString::number(tx,'f',2);
                table2Data[row][6] = QString::number(tx*table2Data[row][3].toInt()-tx,'f',2);
                table2Data[row][7] = "无";
                table2Data[row][8] = "无";
                table2Data[row][9] = "无";
            }else if(table2Data[row][3].toInt()<=1000&&table2Data[row][3].toInt()>100){
                table2Data[row][4] = "20";
                table2Data[row][5] = QString::number(tx,'f',2);
                table2Data[row][6] = QString::number(tx*20-tx,'f',2);
                table2Data[row][7] = QString::number(table2Data[row][3].toInt()/20,'f',2);
                table2Data[row][8] = QString::number(tx,'f',2);
                table2Data[row][9] = QString::number(tx*table2Data[row][3].toInt()/20-tx,'f',2);
            }else if(table2Data[row][3].toInt()>1000){
                table2Data[row][4] = "50";
                table2Data[row][5] = QString::number(tx,'f',2);
                table2Data[row][6] = QString::number(tx*50-tx,'f',2);
                table2Data[row][7] = QString::number(table2Data[row][3].toInt()/50,'f',2);
                table2Data[row][8] = QString::number(tx,'f',2);
                table2Data[row][9] = QString::number(tx*table2Data[row][3].toInt()/50-tx,'f',2);
            }
        }else if(type=="mini-STR"){
            if(table2Data[row][3]=="无"){
                table2Data[row][4] = "无";
                table2Data[row][5] = "无";
                table2Data[row][6] = "无";
                table2Data[row][7] = "无";
                table2Data[row][8] = "无";
                table2Data[row][9] = "无";
            }else if(table2Data[row][3].toInt()<=100){
                table2Data[row][4] = table2Data[row][3];
                table2Data[row][5] = QString::number(tx,'f',2);
                table2Data[row][6] = QString::number(tx*table2Data[row][3].toInt()-tx,'f',2);
                table2Data[row][7] = "无";
                table2Data[row][8] = "无";
                table2Data[row][9] = "无";
            }else if(table2Data[row][3].toInt()<=1000&&table2Data[row][3].toInt()>100){
                table2Data[row][4] = "20";
                table2Data[row][5] = QString::number(tx,'f',2);
                table2Data[row][6] = QString::number(tx*20-tx,'f',2);
                table2Data[row][7] = QString::number(table2Data[row][3].toInt()/20,'f',2);
                table2Data[row][8] = QString::number(tx,'f',2);
                table2Data[row][9] = QString::number(tx*table2Data[row][3].toInt()/20-tx,'f',2);
            }else if(table2Data[row][3].toInt()>1000){
                table2Data[row][4] = "50";
                table2Data[row][5] = QString::number(tx,'f',2);
                table2Data[row][6] = QString::number(tx*50-tx,'f',2);
                table2Data[row][7] = QString::number(table2Data[row][3].toInt()/50,'f',2);
                table2Data[row][8] = QString::number(tx,'f',2);
                table2Data[row][9] = QString::number(tx*table2Data[row][3].toInt()/50-tx,'f',2);
            }
        }
    }
}
// 各个类型数量
QList<int> UploadFile::typeNum(){
    QList<int> val;
    int all=0,c=0,y=0,m=0,xs=0;
    for(int i=0;i<table2Data.length();i++){
        if(table2Data[i][0]!=" "){
            all++;
        }
    }
    for(int i=0;i<table2Data.length();i++){
        if(table2Data[i][2].contains("常STR")&&table2Data[i][0]!=" "){
            c++;
        }
    }
    y=all;
    for(int i=2;i<table2Data.length();i++){
        if(table2Data[i][2].contains("mini-STR")&&table2Data[i][0]!=" "){
            m++;
        }
    }
    for(int i=2;i<table2Data.length();i++){
        if(!table2Data[i][3].contains("无")&&table2Data[i][0]!=" "){
            xs++;
        }
    }
    val<<all<<c<<y<<m<<xs;
    return val;
}
// 表格筛选
QVector<QStringList> UploadFile::tab2Fil(QString type){
    if(type=="Y-STR"){
        YSTRfl=true;
    }
    if(type=="全部"){
        datain();
        tabifl=1;
    }else if(type=="常STR"){
        datain();
        for(int i = table2Data.length() - 1; i >= 0; i--){
            if(table2Data[i][2] != "常STR"){
                table2Data.remove(i);
            }
        }
        tabifl=2;
    }else if(type=="mini-STR"){
        datain();
        for(int i = table2Data.length() - 1; i >= 0; i--){
            if(table2Data[i][2] != "mini-STR"){
                table2Data.remove(i);
            }
        }
        tabifl=3;
    }else if(type=="Y-STR"){
        datain();
        for(int i = table2Data.length() - 1; i >= 0; i--){
            if(table2Data[i][2] != "Y-STR"){
                table2Data.remove(i);
            }
        }
        tabifl=4;
    }else if(type=="需稀释样本"){
        datain();
        for(int i = table2Data.length() - 1; i >= 0; i--){
            if(table2Data[i][3] == "无"){
                table2Data.remove(i);
            }
        }
        tabifl=5;
    }
    if(type=="Y-STR"){
        YSTRfl=false;
    }
    return table2Data;
}
// 传表一
QVariantList UploadFile::getGuideTable1(){
    qDebug()<<table1Data;
    QVariantList lists;
    int idx = 1;
    for(int i = 0; i < table1Data.size(); i ++){
        QVariantList list;
        list.append(idx);
        for(int j = 0; j < table1Data[i].size(); j ++){
            list.append(table1Data[i][j]);
        }
        lists.push_back(list);
        idx ++;
    }
    return lists;
}
// 传表二
QVariantList UploadFile::getGuideTable2(QString type){

    if(type != ""){
        tab2Fil(type);
    }

    QVariantList lists;

    int idx = 1;
    for(int i = 0; i < table2Data.size(); i ++){
        if(table2Data[i][0]==" "){

        }else{
            QVariantList list;
            list.append(idx);
            for(int j = 0; j < table2Data[i].size(); j ++){
                list.append(table2Data[i][j]);
            }
            lists.push_back(list);
            idx ++;
        }


    }
    return lists;
}
// AL AS Y
Q_INVOKABLE QVariantList UploadFile::tran(){
    QVariantList trans;
    trans<<Y<<AS<<AL;
    return trans;
}
// 数据导出
Q_INVOKABLE void UploadFile::datao()
{
    int tabnum = tabifl;
    QString path=QString("/path/to/default/%1").arg("");
    QString filePath = QFileDialog::getSaveFileName(nullptr, "保存", path,"Excel Files (*.xlsx)");

    QList<QString> allInfo;
    QList<QString> YstrInfo;
    QList<QString> MiniStrInfo;

    qDebug()<<table2Data;
    if(filePath.isEmpty()&&filePath.isNull()){
        return;
    }
    else
    {
        QXlsx::Document xlsx;

        int finalRowNum=4;
        xlsx.addSheet("下游操作建议");

        xlsx.write("A1","总数:");
        xlsx.write("B1","常STR:");
        xlsx.write("C1","mini-STR:");
        xlsx.write("D1","Y-STR数量:");
        xlsx.write("F1","需稀释样本数量:");

        xlsx.write("A2","样品位置(所有样品)");
        xlsx.write("B2","检材编号");
        xlsx.write("C2","检测方案(链接常-STR模型“检测方案”)");
        xlsx.write("D2","总稀释倍数DFa(链接常-STR模型相应“总稀释倍数DFa”)");
        xlsx.mergeCells("E2:G2");
        xlsx.write("E2","第一步稀释方案");
        xlsx.mergeCells("H2:J2");
        xlsx.write("H2","第二步稀释方案");
        xlsx.write("K2","STR扩增模板体积(链接常、Mini-STR模型相应“STR扩增模板体积”)");
        xlsx.write("L2","备注");

        xlsx.write("E3","稀释倍数1 \n DFa1");
        xlsx.write("F3","样品体积(ul)");
        xlsx.write("G3","稀释液体积(ul)");
        xlsx.write("H3","稀释倍数2 \n DFa1");
        xlsx.write("I3","上一步稀释产物(ul)");
        xlsx.write("J3","稀释液体积(ul)");

        QList<QString> label;
        label<<""<<"A"<<"B"<<"C"<<"D"<<"E"<<"F"<<"G"<<"H"<<"I"<<"J"<<"K"<<"L";

        tab2Fil("全部");

        if(table2Data.length()>0){
            for (int i=0;i<table2Data.count();i++)
            {
                QString pos=table2Data[i][0];
                if(pos==" "){
                    continue;
                }
                for (int m=1;m<label.length();m++) {
                    QString info;
                    QString item = table2Data[i][m-1];
                    if(item==" "){
                        info="——";
                    }else{
                        info =table2Data[i][m-1];

                    }
                    if(m==4 && (info=="——" || info=="无"))
                    {
                        xlsx.mergeCells("E"+QString::number(finalRowNum)+":"+"G"+QString::number(finalRowNum));
                        xlsx.write("E"+QString(finalRowNum),info);
                        m=7;
                    }
                    else if(m==7 && (info=="——" || info=="无")){
                        xlsx.mergeCells("H"+QString::number(finalRowNum)+":"+"J"+QString::number(finalRowNum));
                        xlsx.write("H"+QString::number(finalRowNum),info);
                        m=10;
                    }else{
                        xlsx.write(label[m]+QString::number(finalRowNum),info);
                    }
                }
                finalRowNum++;
            }
        }
        else{
            finalRowNum = 6;
        }

        xlsx.write("A"+QString::number(finalRowNum),"筛选:需稀释检材");

        xlsx.write("A"+QString::number(finalRowNum+1),"样品位置(所有样品)");
        xlsx.write("B"+QString::number(finalRowNum+1),"检材编号");
        xlsx.write("C"+QString::number(finalRowNum+1),"检测方案(链接常-STR模型“检测方案”)");
        xlsx.write("D"+QString::number(finalRowNum+1),"总稀释倍数DFa(链接常-STR模型相应“总稀释倍数DFa”)");
        xlsx.mergeCells("E"+QString::number(finalRowNum+1)+":"+"G"+QString::number(finalRowNum+1));
        xlsx.write("E"+QString::number(finalRowNum+1),"第一步稀释方案");
        xlsx.mergeCells("H"+QString::number(finalRowNum+1)+":"+"J"+QString::number(finalRowNum+1));
        xlsx.write("H"+QString::number(finalRowNum+1),"第二步稀释方案");
        xlsx.write("K"+QString::number(finalRowNum+1),"STR扩增模板体积(链接常、Mini-STR模型相应“STR扩增模板体积”)");
        xlsx.write("L"+QString::number(finalRowNum+1),"备注");

        xlsx.write("E"+QString::number(finalRowNum+2),"稀释倍数1 \r DFa1");
        xlsx.write("F"+QString::number(finalRowNum+2),"样品体积(ul)");
        xlsx.write("G"+QString::number(finalRowNum+2),"稀释液体积(ul)");
        xlsx.write("H"+QString::number(finalRowNum+2),"稀释倍数2 \n DFa1");
        xlsx.write("I"+QString::number(finalRowNum+2),"上一步稀释产物(ul)");
        xlsx.write("J"+QString::number(finalRowNum+2),"稀释液体积(ul)");

        tab2Fil("需稀释样本");
        if(table2Data.length()>0){
            finalRowNum=finalRowNum+3;
            for (int i=0;i<table2Data.count();i++)
            {
                QString pos=table2Data[i][0];
                if(pos==" "){
                    continue;
                }
                for (int m=1;m<label.length();m++) {
                    QString info;
                    QString item = table2Data[i][m-1];
                    if(item==" "){
                        info="——";
                    }else{
                        info =table2Data[i][m-1];

                    }
                    if(m==4 && (info=="——" || info=="无"))
                    {
                        xlsx.mergeCells("E"+QString::number(finalRowNum)+":"+"G"+QString::number(finalRowNum));
                        xlsx.write("E"+QString(finalRowNum),info);
                        m=7;
                    }
                    else if(m==7 && (info=="——" || info=="无")){
                        xlsx.mergeCells("H"+QString::number(finalRowNum)+":"+"J"+QString::number(finalRowNum));
                        xlsx.write("H"+QString::number(finalRowNum),info);
                        m=10;
                    }else{

                        xlsx.write(label[m]+QString::number(finalRowNum),info);
                    }
                }
                finalRowNum++;
            }
        }else{
            finalRowNum=11;
        }

        xlsx.write("A"+QString::number(finalRowNum),"筛选:需做Y-STR检材");

        xlsx.write("A"+QString::number(finalRowNum+1),"样品位置(所有样品)");
        xlsx.write("B"+QString::number(finalRowNum+1),"检材编号");
        xlsx.write("C"+QString::number(finalRowNum+1),"检测方案(链接常-STR模型“检测方案”)");
        xlsx.write("D"+QString::number(finalRowNum+1),"总稀释倍数DFa(链接常-STR模型相应“总稀释倍数DFa”)");
        xlsx.mergeCells("E"+QString::number(finalRowNum+1)+":"+"G"+QString::number(finalRowNum+1));
        xlsx.write("E"+QString::number(finalRowNum+1),"第一步稀释方案");
        xlsx.mergeCells("H"+QString::number(finalRowNum+1)+":"+"J"+QString::number(finalRowNum+1));
        xlsx.write("H"+QString::number(finalRowNum+1),"第二步稀释方案");
        xlsx.write("K"+QString::number(finalRowNum+1),"STR扩增模板体积(链接常、Mini-STR模型相应“STR扩增模板体积”)");
        xlsx.write("L"+QString::number(finalRowNum+1),"备注");

        xlsx.write("E"+QString::number(finalRowNum+2),"稀释倍数1 \r DFa1");
        xlsx.write("F"+QString::number(finalRowNum+2),"样品体积(ul)");
        xlsx.write("G"+QString::number(finalRowNum+2),"稀释液体积(ul)");
        xlsx.write("H"+QString::number(finalRowNum+2),"稀释倍数2 \n DFa1");
        xlsx.write("I"+QString::number(finalRowNum+2),"上一步稀释产物(ul)");
        xlsx.write("J"+QString::number(finalRowNum+2),"稀释液体积(ul)");


        tab2Fil("Y-STR");
        if(table2Data.length()>0){
            finalRowNum=finalRowNum+3;
            for (int i=0;i<table2Data.count();i++)
            {
                QString pos=table2Data[i][0];
                if(pos==" "){
                    continue;
                }
                for (int m=1;m<label.length();m++) {
                    QString info;
                    QString item = table2Data[i][m-1];
                    if(item==" "){
                        info="——";
                    }else{
                        info =table2Data[i][m-1];

                    }
                    if(m==4 && (info=="——" || info=="无"))
                    {
                        xlsx.mergeCells("E"+QString::number(finalRowNum)+":"+"G"+QString::number(finalRowNum));
                        xlsx.write("E"+QString(finalRowNum),info);
                        m=7;
                    }
                    else if(m==7 && (info=="——" || info=="无")){
                        xlsx.mergeCells("H"+QString::number(finalRowNum)+":"+"J"+QString::number(finalRowNum));
                        xlsx.write("H"+QString::number(finalRowNum),info);
                        m=10;
                    }else{

                        xlsx.write(label[m]+QString::number(finalRowNum),info);
                    }
                }
                finalRowNum++;
            }
        }
        else
        {
            finalRowNum=16;
        }

        xlsx.write("A"+QString::number(finalRowNum),"筛选:需做mini-STR检材");

        xlsx.write("A"+QString::number(finalRowNum+1),"样品位置(所有样品)");
        xlsx.write("B"+QString::number(finalRowNum+1),"检材编号");
        xlsx.write("C"+QString::number(finalRowNum+1),"检测方案(链接常-STR模型“检测方案”)");
        xlsx.write("D"+QString::number(finalRowNum+1),"总稀释倍数DFa(链接常-STR模型相应“总稀释倍数DFa”)");
        xlsx.mergeCells("E"+QString::number(finalRowNum+1)+":"+"G"+QString::number(finalRowNum+1));
        xlsx.write("E"+QString::number(finalRowNum+1),"第一步稀释方案");
        xlsx.mergeCells("H"+QString::number(finalRowNum+1)+":"+"J"+QString::number(finalRowNum+1));
        xlsx.write("H"+QString::number(finalRowNum+1),"第二步稀释方案");
        xlsx.write("K"+QString::number(finalRowNum+1),"STR扩增模板体积(链接常、Mini-STR模型相应“STR扩增模板体积”)");
        xlsx.write("L"+QString::number(finalRowNum+1),"备注");

        xlsx.write("E"+QString::number(finalRowNum+2),"稀释倍数1 \r DFa1");
        xlsx.write("F"+QString::number(finalRowNum+2),"样品体积(ul)");
        xlsx.write("G"+QString::number(finalRowNum+2),"稀释液体积(ul)");
        xlsx.write("H"+QString::number(finalRowNum+2),"稀释倍数2 \n DFa1");
        xlsx.write("I"+QString::number(finalRowNum+2),"上一步稀释产物(ul)");
        xlsx.write("J"+QString::number(finalRowNum+2),"稀释液体积(ul)");


        tab2Fil("mini-STR");
        if(table2Data.length()>0){
            finalRowNum=finalRowNum+3;
            for (int i=0;i<table2Data.count();i++)
            {
                QString pos=table2Data[i][0];
                if(pos==" "){
                    continue;
                }
                for (int m=1;m<label.length();m++) {
                    QString info;
                    QString item = table2Data[i][m-1];
                    if(item==" "){
                        info="——";
                    }else{
                        info =table2Data[i][m-1];

                    }
                    if(m==4 && (info=="——" || info=="无"))
                    {
                        xlsx.mergeCells("E"+QString::number(finalRowNum)+":"+"G"+QString::number(finalRowNum));
                        xlsx.write("E"+QString(finalRowNum),info);
                        m=7;
                    }
                    else if(m==7 && (info=="——" || info=="无")){
                        xlsx.mergeCells("H"+QString::number(finalRowNum)+":"+"J"+QString::number(finalRowNum));
                        xlsx.write("H"+QString::number(finalRowNum),info);
                        m=10;
                    }else{
                        xlsx.write(label[m]+QString::number(finalRowNum),info);
                    }
                }
                finalRowNum++;
            }
        }

        xlsx.addSheet("加样表格");

        QList<QString> rowList;
        rowList<<"B"<<"C"<<"D"<<"E"<<"F"<<"G"<<"H"<<"I"<<"J"<<"K"<<"L"<<"M";

        QList<QString> columList;
        columList<<"A"<<"B"<<"C"<<"D"<<"E"<<"F"<<"G"<<"H";


        xlsx.write("A1","常-STR加样表格");
        for (int i=0;i<rowList.length();i++) {
            xlsx.write(rowList[i]+"2",QString::number(i+1));
        }
        for (int i=0;i<columList.length();i++)
        {
            xlsx.write("A"+QString::number(i+3),columList[i]);
        }

        xlsx.write("A12","Y-STR加样表格");
        for (int i=0;i<rowList.length();i++) {
            xlsx.write(rowList[i]+"13",QString::number(i+1));
        }
        for (int i=0;i<columList.length();i++)
        {
            xlsx.write("A"+QString::number(i+14),columList[i]);
        }

        xlsx.write("A23","mini-STR加样表格");
        for (int i=0;i<rowList.length();i++) {
            xlsx.write(rowList[i]+"24",QString::number(i+1));
        }
        for (int i=0;i<columList.length();i++)
        {
            xlsx.write("A"+QString::number(i+25),columList[i]);
        }

        tab2Fil("全部");
        for (int i=0;i<table2Data.count();i++){
            QString pos=table2Data[i][0];
            if(pos==" "){
                continue;
            }

            QString info;
            QString item = table2Data[i][10];
            if(item==""){
                info="——";
            }else{
                info =table2Data[i][10];
            }

            QString rowInfo;
            QString colInfo;

            if(pos.length()==3){
                rowInfo= pos.left(1);
                colInfo=pos.right(2);
            }else{
                rowInfo= pos.left(1);
                colInfo=pos.right(1);
            }
            QString finalPos = rowList[colInfo.toInt()-1]+ QString::number(columList.indexOf(rowInfo)+3);
            xlsx.write(finalPos,info);
        }

        tab2Fil("Y-STR");
        for (int i=0;i<table2Data.count();i++){
            QString pos=table2Data[i][0];
            if(pos==" "){
                continue;
            }
            QString info;
            QString item = table2Data[i][10];
            if(item==""){
                info="——";
            }else{
                info =table2Data[i][10];
            }
            QString rowInfo;
            QString colInfo;

            if(pos.length()==3){
                rowInfo= pos.left(1);
                colInfo=pos.right(2);
            }else{
                rowInfo= pos.left(1);
                colInfo=pos.right(1);
            }


            QString finalPos = rowList[colInfo.toInt()-1]+ QString::number(columList.indexOf(rowInfo)+14);

            xlsx.write(finalPos,info);
        }

        tab2Fil("mini-STR");
        for (int i=0;i<table2Data.count();i++){
            QString pos=table2Data[i][0];
            if(pos==" "){
                continue;
            }
            QString info;
            QString item = table2Data[i][10];
            if(item==""){
                info="——";
            }else{
                info =table2Data[i][10];
            }
            QString rowInfo;
            QString colInfo;

            if(pos.length()==3){
                rowInfo= pos.left(1);
                colInfo=pos.right(2);
            }else{
                rowInfo= pos.left(1);
                colInfo=pos.right(1);
            }

            QString finalPos = rowList[colInfo.toInt()-1]+ QString::number(columList.indexOf(rowInfo)+25);

            xlsx.write(finalPos,info);
        }

        xlsx.saveAs(filePath);
    }
    if(tabnum==1){
        tab2Fil("全部");
    }else if(tabnum==2){
        tab2Fil("常STR");
    }else if(tabnum==3){
        tab2Fil("Y-STR");
    }else if(tabnum==4){
        tab2Fil("mini-STR");
    }else if(tabnum==5){
        tab2Fil("需稀释样本");
    }
    QMessageBox::information(nullptr,"提示","导出成功！");
}
